package com.gwl.concurrent.syncblock;

public class Pair {

	private int x; 
	private int y; 
	public Pair() { 
		this(0, 0); 
	}
	public Pair(int x, int y) { 
		this.x = x; 
		this.y = y; 
	} 
	public int getX() { 
		return x; 
	} 
	public int getY() { 
		return y; 
	}
	public void incrementX() { 
		x ++; 
	} 
	public void incrementY() { 
		y ++; 
	}
	public void checkState() { 
		if(x != y) 
			throw new PairValuesNotEqualException(); 
	} 
	
	public String toString() { 
		return "x: " + x + ", y: " + y; 
	} 
	
	public class PairValuesNotEqualException extends RuntimeException { 
		private static final long serialVersionUID = -3858191924790742717L;
		public PairValuesNotEqualException() { 
			super("Pair values not equal: " + Pair.this); 
		}
	}
}
